package com.nbicc.anon.news.controller;

import com.nbicc.common.ResponseObj;
import com.nbicc.news.service.INewsService;
import com.nbicc.news.vo.News;
import com.nbicc.parent.listener.OnVisitListener;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.async.DeferredResult;

import javax.annotation.Resource;
import java.util.Map;

@Api(value = "新闻整体(匿名)" )
@RestController
@RequestMapping(value = "/anon/news")
public class AnonNewsController {

    @Resource(name = "NewsServiceImpl")
    private INewsService newsService;
    @Resource(name = "NewsVisitListenerImpl")
    private OnVisitListener newsVisitListenerImpl;

    @ApiOperation(value = "按id查询新闻")
    @GetMapping("/id/{id}")
    @ResponseBody
    public ResponseObj selectById(@PathVariable long id) throws Exception {
        News news = newsService.selectById(id);
        newsVisitListenerImpl.visit(id);
        return ResponseObj.success().setResult(news);
    }

}
